package com.wysql.ascost.controller.info;

import com.wysql.ascost.common.base.BaseController;
import com.wysql.ascost.common.domain.AjaxResult;
import com.wysql.ascost.common.domain.ResultTable;
import com.wysql.ascost.model.custom.Tablepar;
import com.github.pagehelper.PageInfo;
import com.wysql.ascost.model.info.InfoImportresultDtl;
import com.wysql.ascost.service.info.InfoImportresultDtlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

/**
 * 导入操作台账（明细表）Controller
 *
 * @author wysqlauto
 * @ClassName: InfoImportresultDtlController
 * @date 2025-02-25 13:36:14
 */
@Api(value = "导入操作台账（明细表）")
@Controller
@RequestMapping("/InfoImportresultDtlController")
public class InfoImportresultDtlController extends BaseController {

    private String prefix = "info/infoImportresultDtl";

    @Autowired
    private InfoImportresultDtlService infoImportresultDtlService;


    /**
     * 导入操作台账（明细表）页面展示
     *
     * @param model
     * @return String
     * @author wysqlauto
     */
    @ApiOperation(value = "分页跳转", notes = "分页跳转")
    @GetMapping("/view")
    @RequiresPermissions("info:infoImportresultDtl:view")
    public String view(ModelMap model) {
        return prefix + "/list";
    }

    /**
     * list集合
     *
     * @param tablepar
     * @param
     * @return
     */
    //@Log(title = "导入操作台账（明细表）", action = "111")
    @ApiOperation(value = "分页跳转", notes = "分页跳转")
    @GetMapping("/list")
    @RequiresPermissions("info:infoImportresultDtl:list")
    @ResponseBody
    public ResultTable list(Tablepar tablepar, InfoImportresultDtl infoImportresultDtl) {
        PageInfo<InfoImportresultDtl> page = infoImportresultDtlService.list(tablepar, infoImportresultDtl);
        return pageTable(page.getList(), page.getTotal());
    }

    /**
     * 新增跳转
     */
    @ApiOperation(value = "新增跳转", notes = "新增跳转")
    @GetMapping("/add")
    public String add(ModelMap modelMap) {
        return prefix + "/add";
    }

    /**
     * 新增保存
     *
     * @param
     * @return
     */
    //@Log(title = "导入操作台账（明细表）新增", action = "111")
    @ApiOperation(value = "新增", notes = "新增")
    @PostMapping("/add")
    @RequiresPermissions("info:infoImportresultDtl:add")
    @ResponseBody
    public AjaxResult add(InfoImportresultDtl infoImportresultDtl) {
        int b = infoImportresultDtlService.insertSelective(infoImportresultDtl);
        if (b > 0) {
            return success();
        } else {
            return error();
        }
    }

    /**
     * 导入操作台账（明细表）删除
     *
     * @param ids
     * @return
     */
    //@Log(title = "导入操作台账（明细表）删除", action = "111")
    @ApiOperation(value = "删除", notes = "删除")
    @DeleteMapping("/remove")
    @RequiresPermissions("info:infoImportresultDtl:remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        int b = infoImportresultDtlService.deleteByPrimaryKey(ids);
        if (b > 0) {
            return success();
        } else {
            return error();
        }
    }


    /**
     * 修改跳转
     *
     * @param id
     * @param
     * @return
     */
    @ApiOperation(value = "修改跳转", notes = "修改跳转")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap map) {
        map.put("InfoImportresultDtl", infoImportresultDtlService.selectByPrimaryKey(id));

        return prefix + "/edit";
    }

    /**
     * 修改保存
     */
    //@Log(title = "导入操作台账（明细表）修改", action = "111")
    @ApiOperation(value = "修改保存", notes = "修改保存")
    @RequiresPermissions("info:infoImportresultDtl:edit")
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(InfoImportresultDtl infoImportresultDtl) {
        return toAjax(infoImportresultDtlService.updateByPrimaryKeySelective(infoImportresultDtl));
    }

    /**
     * 概算页面查看操作明细列表（本环节）
     *
     * @param tablepar
     * @param
     * @return
     */
    //@Log(title = "导入操作台账（明细表）", action = "111")
    @ApiOperation(value = "分页跳转", notes = "分页跳转")
    @GetMapping("/finddtl")
    @ResponseBody
    public ResultTable finddtl(Tablepar tablepar, InfoImportresultDtl infoImportresultDtl) {
        String step = request.getParameter("step");
        infoImportresultDtl.setStep(Integer.valueOf(step));
        PageInfo<InfoImportresultDtl> page = infoImportresultDtlService.finddtlbyStep(tablepar, infoImportresultDtl);
        return pageTable(page.getList(), page.getTotal());
    }
}
